package com.example.hxds.workflow.bpmn.comment;

import com.example.hxds.workflow.controller.form.SendPrivateMessageForm;
import com.example.hxds.workflow.feign.SnmServiceApi;
import javax.annotation.Resource;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;
/**
 * @Author XUYANG
 * @Date 2024-04-10 14:47
 */
@Component
public class NotifyDriverService implements JavaDelegate {
    @Resource
    private SnmServiceApi snmServiceApi;

    public void execute(DelegateExecution delegateExecution) {
        long driverId = Long.parseLong((String)delegateExecution.getVariable("driverId", String.class));
        long orderId = Long.parseLong((String)delegateExecution.getVariable("orderId", String.class));
        String result = (String)delegateExecution.getVariable("result", String.class);
        String note = (String)delegateExecution.getVariable("note", String.class);
        SendPrivateMessageForm sendPrivateMessageForm = new SendPrivateMessageForm();
        sendPrivateMessageForm.setReceiverIdentity("message");
        sendPrivateMessageForm.setReceiverId(Long.valueOf(driverId));
        sendPrivateMessageForm.setTtl(Integer.valueOf(259200000));
        sendPrivateMessageForm.setSenderId(Long.valueOf(0L));
        sendPrivateMessageForm.setSenderIdentity("system");
        sendPrivateMessageForm.setSenderName("华夏代驾");
        String var9 = "订单号:"+ orderId + "该订单的差评申诉";
        if ("同意".equals(result)) {
        var9 = var9 + "成功";
        } else {
            var9 = var9 + "失败";
            if (note != null){
                var9 = var9 + "。"+ var9;
            }
        }
        sendPrivateMessageForm.setMsg(var9);
        this.snmServiceApi.sendPrivateMessageSync(sendPrivateMessageForm);
    }
}

